package factory

import (
	"fmt"
	"goskeleton/app/core/container"
	"goskeleton/app/global/my_errors"
	"goskeleton/app/global/variable"
	"goskeleton/app/http/validator/core/interf"

	"github.com/gin-gonic/gin"
)

// 表单参数验证器工厂（请勿修改）
func Create(key string) func(context *gin.Context) {
	fmt.Printf("验证器工厂 key: %s\n", key)
	if value := container.CreateContainersFactory().Get(key); value != nil {
		fmt.Printf("找到验证器: %+v\n", value)
		if val, isOk := value.(interf.ValidatorInterface); isOk {
			fmt.Printf("验证器转换成功\n")
			return val.CheckParams
		}
		fmt.Printf("验证器转换失败\n")
	}
	fmt.Printf("未找到验证器\n")
	variable.ZapLog.Error(my_errors.ErrorsValidatorNotExists + ", 验证器模块：" + key)
	return nil
}
